import request from '../utils/request';

// 获取用户信息
const getUserInfo = (params) => {
  return request({
    method: 'POST',
    url: '/mini/clock/api/v1/dingtalk/user',
    params
  });
};
// 获取用户信息
const getUserEmployeeInfo = (unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/employee/',
    headers: {
      unionid: unionid || ''
    }
  });
};
// 注册用户信息
const postUserInfo = (params) => {
  return request({
    method: 'POST',
    url: '/mini/clock/api/v1/employee/',
    params,
    headers: {
      unionid: params.unionid || ''
    }
  });
};
// 查询打卡点距离信息
const postNearStation = (params, unionid) => {
  return request({
    method: 'POST',
    url: '/mini/clock/api/v1/punch/card/near/station',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 查询用户上下班时间 当前站点，班次，时间
const getClockStatus = (params, unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/punch/card/status',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 查询外勤用户上下班时间
const getClockOutingStatus = (unionid, longitude, latitude) => {
  return request({
    method: 'GET',
    url: `/mini/clock/api/v1/punch/card/outing/status?longitude=${longitude}&latitude=${latitude}`,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 用户补卡弹窗查
const getClockRemind = (unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/punch/card/remind',
    headers: {
      unionid: unionid || ''
    }
  });
};

// 提交打卡
const postClockPunch = (params) => {
  return request({
    method: 'POST',
    url: '/mini/clock/api/v1/punch/card/',
    params,
    headers: {
      unionid: params.unionid || ''
    }
  });
};
// 提交外勤打卡
const postClockPunchOuting = (params) => {
  return request({
    method: 'POST',
    url: '/mini/clock/api/v1/punch/card/outing',
    params,
    headers: {
      unionid: params.unionid || ''
    }
  });
};
// 查询用户打卡列表(日历视图使用)
const getClockCalenderRecords = (params, unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/punch/card/calender',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 查询用户月度打卡日期列表
const getClockCalenderMonth = (params, unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/punch/card/calender/month',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 获取工地列表
const getStation = (unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/punch/card/station',
    headers: {
      unionid: unionid || ''
    }
  });
};
// 获取用户列表
const getUserList = (unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/employee/list',
    headers: {
      unionid: unionid || ''
    }
  });
};
// 工地补卡
const postReissue = (params) => {
  return request({
    method: 'POST',
    url: '/mini/clock/api/v1/punch/card/addition',
    params,
    headers: {
      unionid: params.unionid || ''
    }
  });
};
// 外勤补卡
const postOutReissue = (params) => {
  return request({
    method: 'POST',
    url: '/mini/clock/api/v1/punch/card/outing/addition',
    params,
    headers: {
      unionid: params.unionid || ''
    }
  });
};
// 外勤审批列表
const getApproveOuting = (params, unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/approve/outing',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 外勤审批提交
const putApproveOuting = (id, params, unionid) => {
  return request({
    method: 'POST',
    url: `/mini/clock/api/v1/approve/outing/${id}`,
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 补卡审批列表
const getApproveAddition = (params, unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/approve/addition',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 外勤审批提交
const putApprovAddition = (id, params, unionid) => {
  return request({
    method: 'POST',
    url: `/mini/clock/api/v1/approve/addition/${id}`,
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 个人补卡列表
const getApproveReocrd = (params, unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/punch/card/approve/record',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 查询待审批数量
const getApprovePreview = (unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/approve/preview',
    headers: {
      unionid: unionid || ''
    }
  });
};
// 站点日度报表
const getReportStationDaily = (params, unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/report/station/daily',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 员工日度报表
const getReportEmployeeDaily = (params, unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/report/employee/daily/report',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 员工日度报表详情
const getReportEmployeeDailyReport = (id, params, unionid) => {
  return request({
    method: 'GET',
    url: `/mini/clock/api/v1/report/employee/${id}/daily/report`,
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};

// 员工日度报表详情列表
const getReportEmployeeDailyCardDetail = (unionid, params) => {
  return request({
    method: 'GET',
    url: `/mini/clock/api/v1/punch/card/daily/records`,
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};

// 删除员工打卡记录
const deleteEmployeeDailyCardRecord = (params, unionid) => {
  console.log('deleteEmployeeDailyCardRecord', params, unionid);
  return request({
    method: 'GET',
    url: `/mini/clock/api/v1/punch/card/delete`,
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};

// 站点周期报表
const getReportStationPeriod = (params, unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/report/station/period',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};

// 员工周期报表
const getReportEmployeePeriod = (params, unionid) => {
  return request({
    method: 'GET',
    url: '/mini/clock/api/v1/report/employee/period',
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};

// 站点周期报表打卡统计
const postExportStationReport = (params, unionid) => {
  return request({
    method: 'POST',
    url: `/mini/clock/api/v1/approve/station/period/report`,
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 用户周期报表打卡统计
const postExportUserReport = (params, unionid) => {
  return request({
    method: 'POST',
    url: `/mini/clock/api/v1/approve/user/period/report`,
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};
// 用户月度报表打卡统计
const postExportUserDetailReport = (params, unionid) => {
  return request({
    method: 'POST',
    url: `/mini/clock/api/v1/approve/user/clock/detail/report`,
    params,
    headers: {
      unionid: unionid || ''
    }
  });
};

export default {
  getUserInfo,
  postUserInfo,
  getStation,
  postReissue,
  postOutReissue,
  postNearStation,
  getClockStatus,
  getClockOutingStatus,
  postClockPunch,
  postClockPunchOuting,
  getClockCalenderRecords,
  getClockCalenderMonth,
  getUserEmployeeInfo,
  getApproveOuting,
  putApproveOuting,
  getApproveAddition,
  putApprovAddition,
  getApproveReocrd,
  getApprovePreview,
  getReportStationDaily,
  getReportEmployeeDaily,
  getReportStationPeriod,
  getReportEmployeePeriod,
  getReportEmployeeDailyReport,
  getReportEmployeeDailyCardDetail,
  deleteEmployeeDailyCardRecord,
  getClockRemind,
  getUserList,
  postExportStationReport,
  postExportUserReport,
  postExportUserDetailReport
};